nums = [0,1,2,4,5,7]
def summaryRanges(nums):
    numsLen=len(nums)
    print(numsLen)
    if numsLen==0:
        return []
    #存放结果的矩阵
    ans=[]
    first=nums[0]
    last=None
    index = 1
    while index<numsLen:
        if nums[index]==nums[index-1]+1:
            last=nums[index]
        else:
            #不连续出现
            if last:
                ans.append(str(first)+"->"+str(last))
            else:
                ans.append(str(first))
            first=nums[index]
            last=None
        index+=1
    if last:
        ans.append(str(first)+"->"+str(last))
    else:
        ans.append(str(first))
    print(ans)


summaryRanges(nums)

